package cn.richard.home.viewmodel

import android.util.Log
import androidx.lifecycle.ViewModel
import cn.richard.home.api.data.PicCategoryList
import cn.richard.base.bean.ResultData
import cn.richard.home.api.repository.PictureRepository

/**
 *
 * @ProjectName: PicApp
 * @Author: wuzhiguo@aiforward.com
 * @CreateDate: 2021/9/2 8:35 上午
 * @Description:
 */
class PicCategoryViewModel(private val repository: PictureRepository): ViewModel() {


    suspend fun getPicCategory(adult: Boolean, first: Int): PicCategoryList?{
        val result: ResultData<PicCategoryList> = repository.getPictureCategories(adult, first)
//        Log.i("getPicCategory", result.toString())
        return if (result.code == 0) {
            Log.i("getPicCategory", result.res?.category?.size.toString())
            result.res
        } else {
            null
        }
    }


}